<?php
	function upload_gif($tmp, $nome, $largura, $pasta){

	$img = imagecreatefromgif($tmp);
	$x = imagesx($img);
	$y = imagesy($img);
	if($x < $y){
		$largura = "400";}
	$altura = ($largura * $y) / $x;
	
	
	$nova = imagecreatetruecolor($largura, $altura);
	imagecopyresampled($nova, $img, 0, 0, 0, 0, $largura, $altura, $x, $y);
	imagedestroy($img);
	
	$marca  = imagecreatefrompng('../Imagens_BG/marca.png');
	$marcax = imagesx($marca);
	$marcay = imagesy($marca);
	$localx = $largura-120;
	$localy = $altura-50;
	imagecopyresampled($nova, $marca, $localx, $localy, 0, 0, 100, 30, $marcax, $marcay);
	imagejpeg($nova, "$pasta/$nome");
	imagedestroy($nova);

	return($nome);}
	
	function upload_jpg($tmp, $nome, $largura, $pasta){

	$img = imagecreatefromjpeg($tmp);
	$x = imagesx($img);
	$y = imagesy($img);
	if($x < $y){
		$largura = "400";}
	$altura = ($largura * $y) / $x;
	
	$nova = imagecreatetruecolor($largura, $altura);
	imagecopyresampled($nova, $img, 0, 0, 0, 0, $largura, $altura, $x, $y);
	imagedestroy($img);
	
	$marca  = imagecreatefrompng('../Imagens_BG/marca.png');
	$marcax = imagesx($marca);
	$marcay = imagesy($marca);
	$localx = $largura-120;
	$localy = $altura-50;
	imagecopyresampled($nova, $marca, $localx, $localy, 0, 0, 100, 30, $marcax, $marcay);
	imagejpeg($nova, "$pasta/$nome");
	imagedestroy($nova);

	return($nome);}
	
	
	function upload_png($tmp, $nome, $largura, $pasta){

	$img = imagecreatefrompng($tmp);
	$x = imagesx($img);
	$y = imagesy($img);
	if($x < $y){
		$largura = "400";}
	$altura = ($largura * $y) / $x;
	
	$nova = imagecreatetruecolor($largura, $altura);
	imagecopyresampled($nova, $img, 0, 0, 0, 0, $largura, $altura, $x, $y);
	imagedestroy($img);
	
	$marca  = imagecreatefrompng('../Imagens_BG/marca.png');
	$marcax = imagesx($marca);
	$marcay = imagesy($marca);
	$localx = $largura-120;
	$localy = $altura-50;
	imagecopyresampled($nova, $marca, $localx, $localy, 0, 0, 100, 30, $marcax, $marcay);
	imagejpeg($nova, "$pasta/$nome");
	imagedestroy($nova);

	return($nome);}


?>